<template>
	<view>
		<view :class="[tabIndex===1?'tabbar-b':'tabbar-w']">
			<block v-for="(it,index) in tabList" :key="index">
				<view class="tab-item" @click="onTab(it,index)" v-if="tabIndex!==index">
					
					<image v-if="tabIndex!==1" class="icon" :src="it.iconPath" mode=""></image>
					<image v-else class="icon" :src="it.iconPathd" mode=""></image>

					<text v-if="tabIndex==1" class="txt-y">{{it.text}}</text>
					<text v-else class="txt-b">{{it.text}}</text>
				</view>
				<view class="tab-item" @click="onTab(it,index)" v-if="tabIndex===index">
					<image class="icon" :src="it.selectedIconPath" mode=""></image>
					<text v-if="tabIndex==1" class="txt-r">{{it.text}}</text>
					<text v-else class="txt-w">{{it.text}}</text>
				</view>
			</block>
		</view>
	</view>
</template>

<script>
	import props from '../../uview-ui/libs/config/props';
	export default {
		name: "tabbar",
		props: {
			tabIndex: {
				type: Number,
				default: 0
			},
		},
		mounted() {},
		data() {
			return {
				tabList: [{
						"pagePath": "pages/home/index",
						"text": "剧场",
						"iconPath": "../../static/tabbar/movie-2-line-w.svg",//未选中
						"iconPathd": "../../static/tabbar/movie-2-line-w.svg",//精选选中时
						"selectedIconPath": "../../static/tabbar/movie-2-fill.svg",//选中时
						"enablePullDownRefresh": true
					},
					{
						"pagePath": "pages/home/wxvideo",
						// "pagePath": "pages/home/video",
						"text": "精选",
						"iconPath": "../../static/tabbar/fire-lines.svg",
						"iconPathd": "../../static/tabbar/fire-lines.svg",
						"selectedIconPath": "../../static/tabbar/fire-fill.svg",
					},
					{
						"pagePath": "pages/home/bonus/bonus",
						"text": "福利",
						"iconPath": "../../static/tabbar/red-packet.svg",
						"iconPathd": "../../static/tabbar/red-packet.svg",
						"selectedIconPath": "../../static/tabbar/red-packet-fill.svg",
					},
					{
						"pagePath": "pages/home/watch",
						"text": "追剧",
						"iconPath": "../../static/tabbar/star-smile.svg",
						"iconPathd": "../../static/tabbar/star-smile.svg",
						"selectedIconPath": "../../static/tabbar/star-smile-fill.svg",
					},
					{
						"pagePath": "pages/home/user",
						"text": "我的",
						"iconPath": "../../static/tabbar/user.svg",
						"iconPathd": "../../static/tabbar/user.svg",
						"selectedIconPath": "../../static/tabbar/user-3-fill.svg",
					}
				]
			};
		},
		methods: {
			onTab(e, i) {
				uni.switchTab({
					url: '/' + e.pagePath
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.tabbar-w {
		border-top: 1px solid #f2f5f7;
		position: fixed;
		bottom: 0;
		width: 100%;
		z-index: 999999;
		background-color: white;
		height: 8vh;
		display: flex;
		align-items: center;
		box-shadow: 0 1rpx 2rpx rgba(0, 0, 0, 0.1);
	}

	.tabbar-b {
		position: fixed;
		bottom: 0;
		width: 100%;
		z-index: 999999;
		background-color: black;
		height: 8vh;
		display: flex;
		align-items: center;
	}

	.tab-item {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		flex: 1;
		height: 100%;
		border-radius: 16rpx;
		position: relative;
	}


	.icon {
		width: 48rpx;
		height: 48rpx;
		margin-bottom: 4rpx;
	}
	// 精选选中状态时精选文本颜色
	.txt-r {
		color: #fff;
		font-size: 24rpx;
	}
	// 精选选中状态时其他文本颜色
	.txt-y {
		color: #b5b5b5;
		font-size: 24rpx;
	}
	// 精选未选中时未选中颜色
	.txt-b {
		color: #b5b5b5;
		font-size: 24rpx;
	}
	// 精选未选中时文本选中颜色
	.txt-w {
		color: #222222;
		font-size: 24rpx;
	}
</style>